Conversation
Fix up the way we implement .assume_init() - use a mapping of the data storage type instead of transmute. The end result is similar anyway but easier to verify that it is correct. See docs for Arc::from_raw for its requirements - which we should now adhere to.
Avoid Array::uninitialized and use maybe_uninit.
bluss
commented
Dec 29, 2020
| /// | ||
| /// Caller must ensure the two types have the same representation. | ||
| unsafe fn data_subst(self) -> Self::Output; | ||
| } |
Member
Author
There was a problem hiding this comment.
Note that the data storage types are never publically available so the user of ndarray can never reach this method and call it.
This was referenced Jan 25, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve
.assume_init()so that we can see that it is on sound ground (and not transmuting wildly).Then the remaining internal uses of
Array::uninitializedare removed and replaced withArray::maybe_uninit.Fixes part of #796
Prerequisite of #804
This pull request demonstrates two different ways of working with
maybe_uninit. In concatenate and stack,we can see how we're using the more "Rust-level" approach of using regular array traversal and interacting with
elements of type
MaybeUninit<A>(by just assigning to them, but still).In the implementation of
dotand the benchmark, we instead use raw array views -RawArrayViewMut,cast the raw view from element type
MaybeUninit<A>toA, and handle the resulting raw view andraw pointers carefully. We have some power in the ndarray abstractions because we can use
Zipto traverse raw views just like regular arrays.